/*
 * pcb.h
 *
 *  Created on: Nov 30, 2011
 *      Author: James
 */

#ifndef PCB_H_
#define PCB_H_
#include <stdlib.h>

typedef enum stateEnum {
	RUNNING,
	READY,
	INTERRUPT,
	BLOCKED
} State;

int next_pid = 0;

//***Instructions from project!***
//Each process should have an associated process control block with a minimum amount of information
//for the scheduler to manage. Process instances should be generated dynamically at start up. For example:

//***Example from the project write up!***
typedef struct pcb_str {
	int	pid;
	int next_step;		// this is the step count that the CPU had gotten to when this process was
						// prempted (like a PC register value)
	State state;			// e.g. 0=running, 1=ready, 2=interrupted, 3=blocked
	int waiting_on;		// which queue is it in if it is waiting on something (blocked)
	int owns;			// which semaphore does it own
	// anything else you need
} PCBStr;


PCBStr* createNewPCB() {
	PCBStr *pcb = malloc(sizeof(*pcb));
	pcb->pid = next_pid;
	next_pid++;
	pcb->state = READY;
	pcb->waiting_on = -1;
	pcb->owns = -1;
	return pcb;
}




#endif /* PCB_H_ */
